package com.qianyucc.blog.controller.admin;

import com.qianyucc.blog.model.vo.*;
import com.qianyucc.blog.service.*;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

/**
 * @author lijing
 * @date 2019-10-24 17:57
 * @description 与评论有关的api
 */
@RestController("adminCommentController")
@RequestMapping("admin/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @ApiOperation("分页展示评论列表")
    @GetMapping("/")
    public PageInfoVO<CommentItemVO> getComment(
            @RequestParam(value = "pageNumber", defaultValue = "1", required = false) Integer pageNumber) {
        PageInfoVO<CommentItemVO> pageInfoVO = commentService.findAllComments(pageNumber);
        return pageInfoVO;
    }

    @ApiOperation("根据id删除对应评论")
    @DeleteMapping("/{id}")
    public ResultVO delById(@PathVariable Long id) {
        commentService.deleteById(id);
        return ResultVO.ok("操作成功！");
    }
}
